package cn.qdu.model;

import java.sql.Date;

public class User {
    private String userId;
    private String nickname;
    private String phone;
    private String email;
    private String avatar;
    private Date birthDate;
    private String gender;
    private String password;
    private int age;
    private int friendCount;
    private int postCount;
    private int mutualFriends;
    private String bio;          // 用户简介


    // 添加好友状态属性
    private boolean isFriend;
    private boolean hasPendingRequest;

    // 构造方法
    public User() {}

    public User(String userId, String nickname, String phone, String email,
                String avatar, Date birthDate, String gender, String password) {
        this.userId = userId;
        this.nickname = nickname;
        this.phone = phone;
        this.email = email;
        this.avatar = avatar;
        this.birthDate = birthDate;
        this.gender = gender;
        this.password = password;
    }

    // Getter和Setter方法

    public Boolean getIsFriend() {
        return isFriend;
    }

    public void setIsFriend(Boolean isFriend) {
        this.isFriend = isFriend;
    }

    public Boolean getHasPendingRequest() {
        return hasPendingRequest;
    }

    public void setHasPendingRequest(Boolean hasPendingRequest) {
        this.hasPendingRequest = hasPendingRequest;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public Date getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(Date birthDate) {
        this.birthDate = birthDate;
        if (birthDate != null) {
            this.age = calculateAge(birthDate);
        }
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getAge() {
        return age;
    }

    public int getFriendCount() {
        return friendCount;
    }

    public void setFriendCount(int friendCount) {
        this.friendCount = friendCount;
    }

    public int getPostCount() {
        return postCount;
    }

    public void setPostCount(int postCount) {
        this.postCount = postCount;
    }

    public int getMutualFriends() {
        return mutualFriends;
    }

    public void setMutualFriends(int mutualFriends) {
        this.mutualFriends = mutualFriends;
    }

    public String getBio() {
        return bio;
    }

    public void setBio(String bio) {
        this.bio = bio;
    }

    // 辅助方法
    private int calculateAge(Date birthDate) {
        long ageInMillis = System.currentTimeMillis() - birthDate.getTime();
        return (int) (ageInMillis / (1000L * 60 * 60 * 24 * 365));
    }

    @Override
    public String toString() {
        return "User{" +
                "userId='" + userId + '\'' +
                ", nickname='" + nickname + '\'' +
                ", phone='" + phone + '\'' +
                ", email='" + email + '\'' +
                '}';
    }


}